package com.sanyog.util;

import java.io.IOException;
import java.sql.Date;

import javax.faces.application.ResourceHandler;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.*;

public class AuthorizationFilter extends GenericServlet implements Filter {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chain) throws ServletException, IOException {
		HttpServletRequest req = (HttpServletRequest) request;
		HttpServletResponse res = (HttpServletResponse) response;
		System.out.println("m in *******"+req.getRequestURI());
		if (req.getRequestURI().contains(".nocache.")
				|| !req.getRequestURI().startsWith(
						req.getContextPath()
								+ ResourceHandler.RESOURCE_IDENTIFIER)) {
			System.out.println("m in");
			//res.setHeader("Cache-Control","no-cache, no-store, must-revalidate"); // HTTP 1.1.
			//res.setHeader("Pragma", "no-cache"); // HTTP 1.0.
			//res.setDateHeader("Expires", -1); // Proxies.
		}

	}

	@Override
	public void destroy() {
		// TODO Auto-generated method stub

	}

	@Override
	public void init(FilterConfig arg0) throws ServletException {
	} // You need to override init() and destroy() as well, but they can be kept
		// empty.

	@Override
	public void service(ServletRequest arg0, ServletResponse arg1)
			throws ServletException, IOException {
		// TODO Auto-generated method stub

	}

}
